<?php
class Notification extends CI_Controller {
	
	public function __construct() {
		parent::__construct ();
		$this->load->model('notification_model');
	}
	
	public function index(){
		
		$uid = $this->session->userdata('user_id');
		
		if ($uid){
			$notifications = $this->notification_model->get_by_user($uid);
			if($notifications){
				$this->load->view('notification/notification',array('notifications'=>$notifications));
			}
		}
	}
	
	public function view($nid){
		$notifications = $this->notification_model->get($nid);
		$this->notification_model->delete($nid);
		redirect($notifications['view_link']);
	}
	
	public function action($nid){
		$notifications = $this->notification_model->get($nid);
		$this->notification_model->delete($nid);
		file_get_contents($notifications['action_link']);
	}
	
	public function cancel($nid){
		$notifications = $this->notification_model->get($nid);
		$this->notification_model->delete($nid);
		file_get_contents($notifications['cancel_link']);
	}
}

?>